package com.javaemaildemo.job;

import com.javaemaildemo.service.impl.EmailService;
import org.quartz.Job;
import org.quartz.JobExecutionContext;
import org.quartz.JobExecutionException;
import org.springframework.beans.factory.annotation.Autowired;

import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;

/**
 * @author MAXIAO
 * @create 2021-09-07-14:46
 */
public class AttachMailJob implements Job {

    @Autowired
    EmailService emailService;

    @Override
    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException {
        //打印当前的执行时间 例如 2017-11-23 00:00:00
        Date date = new Date();
        SimpleDateFormat sf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
        System.out.println("现在的时间是：" + sf.format(date));
        //具体的业务逻辑
        System.out.println("开始任务");
//        emailService.sendAttachmentMail("2063587660@qq.com", "定时发送时", "下午好");
        ArrayList<String> fileLists = new ArrayList<>();
        fileLists.add("D:\\工作日志.xlsx");
        emailService.sendAttachmentMail("1834884307@qq.com", "定时发送", "下午好", fileLists);
    }
}
